<?php
/**
 * @Copyright   2008, XXXX-XXXX
 * All rights reserved. 
 * feature summary.
 * @filesource  GetPlayerCommand.php
 * @author      lipeng <lipengage@gmain.com> 
 * @package     / 
 * @version     $Id: $ 
 */

class GetPlayerCommand extends command{
	public function excute() {
		$userdb = new user_dao();
		$activitydb = new activity_dao();

		$container = $this->request['ctn'];
		$uid = empty($this->request["id"]) ? $this->request["vid"] : $this->request["id"];
		
		if (empty($container) || empty($uid)) {
			$this->set_messageid(command::$PARAM_ERROR);
			return true;
		}
		
		$user = $userdb->user_get_byid($container, $uid);
		if ($user['count'] < 1) {
			$this->set_messageid(command::$PLAYER_NOT_FOUND);
			return true;
		}
		else {
			$this->set_haserror(false);
			$user = $user["result"][0];
			$params = array();
			$params[$user["uid"]] = $user;
			$activity = $activitydb->activity_get_user_last_activitys($container, $uid);
			if ($activity["count"] > 0) {
				$params["activities"] = $activity["result"];
			}
			else {
				$params["activities"] = '';
			}
			$slaves = $userdb->user_get_slave($container, $uid);
			if ($slaves["count"] < 1) {
				$params["slaves"] = '';
			}
			else {
				foreach($slaves["result"] as $v) {
					$params["slaves"][$v["uid"]] = $v;
				}
			}
			$user["userId"] = $user["uid"];
			$this->set_data($user["uid"], $user);
			$this->set_data("activities", $params["activities"]);
			$this->set_data("slaves", $params["slaves"]);
		}
		return false;
	}
}
?>